using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.VisualBasic;
using System.Data;


namespace BetterControls {
    [DefaultProperty("Text"), ToolboxData("<{0}:BetterDropDownList runat=server></{0}:BetterDropDownList>")]
    public class BetterDropDownList : System.Web.UI.WebControls.DropDownList {

        //TODO: Need property for warning tag, property to turn off enhanced behavior, possibly different tag if the bad value is null or blank

        

        protected override void OnDataBinding(System.EventArgs e) {
            try {
                base.OnDataBinding(e);
            }
            catch (System.ArgumentOutOfRangeException OutOfRangeEx) {
                //Was GridViewRow
                IDataItemContainer gvr = (IDataItemContainer)this.NamingContainer;
                DataRowView drv = (DataRowView)gvr.DataItem;
                string v = drv[this.DataValueField].ToString();
                this.ClearSelection();
                ListItem li = new ListItem("BAD:" + v, v);
                li.Selected = true;
                this.Items.Insert(0, li);
            }
            catch (Exception ex) {
                throw ex;
            }

        }

    }

}